import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-10-19
 * Time: 15:31
 */
public class Test {

    // 方法：判断一个数是否为素数
    public static boolean isPrime(int num) {
        if (num <= 1) {
            return false;
        }
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }

    // 方法：找到并输出所有的素数因子
    public static void findPrimeFactors(int number) {
        System.out.println("The prime factors of " + number + " are:");
        for (int i = 2; i <= number; i++) {
            while (isPrime(i) && number % i == 0) {
                System.out.print(i + " ");
                number /= i;
            }
        }
        // 如果 number 本身就是一个大素数且未被完全分解，则输出它
        if (number > 1) {
            System.out.print(number);
        }
        System.out.println();
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter a number: ");
        int number = scanner.nextInt();

        findPrimeFactors(number);

        scanner.close();
    }
}
